package com.byedu.focus;

import com.byedu.base.BaseService;
import com.byedu.domain.focus.FocusNoticeDO;
import com.byedu.domain.focus.FocusUserDO;
import com.byedu.domain.focus.vo.enumvos.*;
import com.byedu.domain.focus.vo.FocusUserVO;
import com.byedu.mapper.focus.FocusNoticeMapper;
import com.byedu.mapper.focus.FocusUserMapper;
import com.byedu.util.IDGeneratorUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by jason on 2017/5/14.
 */
@Service
public class FocusUserService extends BaseService {


    @Autowired
    FocusNoticeMapper focusNoticeMapper;
    @Autowired
   FocusUserMapper focusUserMapper;

   public FocusUserVO getFocusUser(FocusUserDO focusUserDO){
       FocusUserDO havecheckFocusUserDO =focusUserMapper.checkFocusUser(focusUserDO);
       return  new FocusUserVO(havecheckFocusUserDO);
    }

    public FocusUserVO getsendFocusUser(FocusUserDO focusUserDO){

        FocusUserDO havecheckFocusUserDO =focusUserMapper.getsendFocusUser(focusUserDO);
        return  new FocusUserVO(havecheckFocusUserDO);

    }
    public FocusUserVO getFocusUserbyUserId(String userId){
        FocusUserDO focusUserDO =focusUserMapper.getFoucUserByUserId(userId);

        return  new FocusUserVO(focusUserDO);
    }

    public Integer addFocusUser(FocusUserDO focusUserDO){
        //设置32位UserId
        focusUserDO.setId(IDGeneratorUtil.generateKeyByUUID());
        return  focusUserMapper.addFocusUser(focusUserDO);
    }

    public Integer updateFocusUserUserId(FocusUserDO focusUserDO) {
        return  focusUserMapper.updateFocusUserDObyUserId(focusUserDO);
    }

    public Integer delFocusUser(FocusUserDO focusUserDO) {
        return focusUserMapper.delFocusUser(focusUserDO);
    }

    public List<FocusUserVO> getFocusUserList() {
        List<FocusUserVO> newVolist = new ArrayList<FocusUserVO>();
        for (FocusUserDO focusUserDO :focusUserMapper.getFoucUserList()){
            newVolist.add(new FocusUserVO(focusUserDO));
        }
        return newVolist;
    }

    public List<FocusUserVO> getFocusUserbydapartList(int depart) {
        List<FocusUserVO> newVolist = new ArrayList<FocusUserVO>();
        for (FocusUserDO focusUserDO : focusUserMapper.getFocusUserbydapartList(depart)){
            newVolist.add(new FocusUserVO(focusUserDO));
        }
        return newVolist;
    }

    public List<FocusdepaTypeVO> listFocusdepaTypeVO() {
        List<FocusdepaTypeVO> list = new ArrayList<FocusdepaTypeVO>();

        for (FocusdepaTypeEnum focusdepaTypeEnum : FocusdepaTypeEnum.values()) {
            FocusdepaTypeVO focusdepaTypeVO = new FocusdepaTypeVO(focusdepaTypeEnum);
            list.add(focusdepaTypeVO);
        }

        return list;
    }

    public List<FocusDepartmentTypeVO> listFocusDepartmentTypeVO() {
        List<FocusDepartmentTypeVO> list = new ArrayList<FocusDepartmentTypeVO>();

        for (FocusDepartmentTypeEnum focusdepaTypeEnum : FocusDepartmentTypeEnum.values()) {
            FocusDepartmentTypeVO focusdepaTypeVO = new FocusDepartmentTypeVO(focusdepaTypeEnum);
            list.add(focusdepaTypeVO);
        }

        return list;
    }

    public List<FocusExecuteTypeVO> listFocusexecuteTypeVO() {
        List<FocusExecuteTypeVO> list = new ArrayList<FocusExecuteTypeVO>();

        for (FocusExecuteTypeEnum focusdepaTypeEnum : FocusExecuteTypeEnum.values()) {
            FocusExecuteTypeVO focusdepaTypeVO = new FocusExecuteTypeVO(focusdepaTypeEnum);
            list.add(focusdepaTypeVO);
        }

        return list;
    }

    public List<FocusUserVO> getFocusUserListbypermission(int permission) {
        List<FocusUserVO> newVolist = new ArrayList<FocusUserVO>();
        for (FocusUserDO focusUserDO :focusUserMapper.getFocusUserListbypermission(permission)){
            newVolist.add(new FocusUserVO(focusUserDO));
        }
        return newVolist;
    }

    public List<FocusUserVO> getFocusUserListbyName(String key) {

        List<FocusUserVO> newVolist = new ArrayList<FocusUserVO>();
        for (FocusUserDO focusUserDO :focusUserMapper.getFocusUserListbyName(key)){
            newVolist.add(new FocusUserVO(focusUserDO));
        }
        return newVolist;
    }


    public Integer updateFocusNoticeDO(FocusNoticeDO focusNoticeDO){
        return  focusNoticeMapper.updateFocusNoticeDO(focusNoticeDO);
    }

    public FocusNoticeDO getFocusNotice(){
        return focusNoticeMapper.getFocusNotice();
    }

    public List<FocusUserVO> getFocusUserListbypermissionpr(int permission) {
        List<FocusUserVO> newVolist = new ArrayList<FocusUserVO>();
        for (FocusUserDO focusUserDO :focusUserMapper.getFocusUserListbypermissionpr(permission)){
            newVolist.add(new FocusUserVO(focusUserDO));
        }
        return newVolist;
    }
}